package com.liu.susu.controller.asny.asny1;

import com.liu.susu.thread.task.async.async1.AsyncTask2;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @FileName AsyncTaskController2
 * @Description
 * @Author susu
 * @date 2022-03-09
 **/
@Controller
@RequestMapping
@Slf4j
public class AsyncTaskController2 {

    @Autowired
    private AsyncTask2 asyncTask2;

    @ResponseBody
    @RequestMapping("/async2")
    public String doMyAllTask() {
//        System.out.println("begin doMyAllTask()-->"
//                + LocalDateTime.now()+"-->"+Thread.currentThread().getName());
        log.info("begin doMyAllTask()...");

        long currentTimeMillis = System.currentTimeMillis();
        asyncTask2.doMyTask1();
        asyncTask2.doMyTask2();
        asyncTask2.doMyTask3();
        long currentTimeMillis1 = System.currentTimeMillis();

        log.info("end doMyAllTask()-->doMyAllTask任务总耗时:"+(currentTimeMillis1-currentTimeMillis)+"ms");

        return "ok";//异步响应
    }


}
